﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bussiness_Objects.BusinessRule
{
    public class ValiadateText
    {
        public static string TrimText(string text)
        {
            text = text.Trim();
            text = System.Text.RegularExpressions.Regex.Replace(text, " +", " ");
            return text;
        }

        public static string UpcaseName(string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                text = TrimText(text);
                char[] letters = text.ToCharArray();
                letters[0] = char.ToUpper(letters[0]);
                for (int i = 1; i < text.Length; i++)
                {
                    if (letters[i - 1] == ' ')
                        letters[i] = char.ToUpper(letters[i]);
                }
                return new string(letters);
            }
            return "";
        }

        public static string UpcaseFirstLetter(string text)
        {
            if (!string.IsNullOrEmpty(text))
            {
                string temp = text.Substring(0, 1);
                return temp.ToUpper() + temp.Remove(0, 1);
            }
            return "";
        }
    }
}
